//
//  PhotoBackupsViewController.m
//  Yarhoo
//
//  Created by 杨春至 on 2018/6/4.
//  Copyright © 2018年 Yarhoo. All rights reserved.
//

#import "PhotoBackupsViewController.h"
#import "BaseNaviViewController.h"
#import "QDMultipleImagePickerPreviewViewController.h"


const NSInteger MaxSelectedImageCount = 100;
@interface PhotoBackupsViewController ()<QMUIAlbumViewControllerDelegate,QMUIImagePickerViewControllerDelegate,QDMultipleImagePickerPreviewViewControllerDelegate>

@end

@implementation PhotoBackupsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    NSLock *lock = [[NSLock alloc]init];
    [lock lock];
    {
        QMUIAlbumViewController *albumViewController = [[QMUIAlbumViewController alloc] init];
        albumViewController.albumViewControllerDelegate = self;
        albumViewController.contentType = QMUIAlbumContentTypeAll;
        [self.navigationController pushViewController:albumViewController  animated:YES];
    }
    [lock unlock];
    
}
- (QMUIImagePickerViewController *)imagePickerViewControllerForAlbumViewController:(QMUIAlbumViewController *)albumViewController{
//    具体相册页面
    QMUIImagePickerViewController *imagePickerViewController = [[QMUIImagePickerViewController alloc] init];
    imagePickerViewController.imagePickerViewControllerDelegate = self;
    imagePickerViewController.maximumSelectImageCount = 30;
    imagePickerViewController.view.tag = albumViewController.view.tag;
    imagePickerViewController.minimumImageWidth = 65;
    
    return imagePickerViewController;
}
- (QMUIImagePickerPreviewViewController *)imagePickerPreviewViewControllerForImagePickerViewController:(QMUIImagePickerViewController *)imagePickerViewController {
//    图片预览页面
    QDMultipleImagePickerPreviewViewController *imagePickerPreviewViewController = [[QDMultipleImagePickerPreviewViewController alloc] init];
        imagePickerPreviewViewController.delegate = self;
        imagePickerPreviewViewController.maximumSelectImageCount = MaxSelectedImageCount;
        imagePickerPreviewViewController.assetsGroup = imagePickerViewController.assetsGroup;
        imagePickerPreviewViewController.view.tag = imagePickerViewController.view.tag;
        return imagePickerPreviewViewController;
}

#pragma mark QMUIImagePickerViewControllerDelegate
- (void)imagePickerViewController:(QMUIImagePickerViewController *)imagePickerViewController didFinishPickingImageWithImagesAssetArray:(NSMutableArray<QMUIAsset *> *)imagesAssetArray{
    
}
#pragma mark - <QMUIImagePickerPreviewViewControllerDelegate>
- (void)imagePickerPreviewViewController:(QDMultipleImagePickerPreviewViewController *)imagePickerPreviewViewController sendImageWithImagesAssetArray:(NSMutableArray<QMUIAsset *> *)imagesAssetArray{
    for (QMUIAsset *asset in imagesAssetArray) {
        NSString *fileName = [asset.phAsset valueForKey:@"filename"];
        NSString *photoIde = asset.assetIdentity;
        NSLog(@"%@",fileName);
        NSLog(@"%@",photoIde);
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
